This presentation features creation of the interactive plots using Plotly as a part of the exploratory data analysis of the dataset ToothGrowth in R.
6 February 2019
This presentation features creation of the interactive plots using Plotly as a part of the exploratory data analysis of the dataset ToothGrowth in R.
library(datasets) data(ToothGrowth)
library(dplyr) str(ToothGrowth) ToothGrowth$dose<-as.factor(ToothGrowth$dose) summary(ToothGrowth)
library(plotly)
# histogram of the tooth length
plot_ly(x=ToothGrowth$len, type="histogram")
# boxplots of the tooth length by the type of supplements
plot1<-ggplot(data=ToothGrowth,aes(x = supp, y = len))+
geom_boxplot(aes(fill=supp))
(gg<-ggplotly(plot1))
# boxplots of the tooth length by the type of supplements and the dose
plot2<-ggplot(data=ToothGrowth,aes(x = supp, y = len))+
geom_boxplot(aes(fill=supp)) + facet_wrap(~ dose)
(gg<-ggplotly(plot2))
library(dplyr) str(ToothGrowth)
## 'data.frame': 60 obs. of 3 variables: ## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ... ## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ... ## $ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
ToothGrowth$dose<-as.factor(ToothGrowth$dose) summary(ToothGrowth)
## len supp dose ## Min. : 4.20 OJ:30 0.5:20 ## 1st Qu.:13.07 VC:30 1 :20 ## Median :19.25 2 :20 ## Mean :18.81 ## 3rd Qu.:25.27 ## Max. :33.90
library(plotly) # histogram of the tooth length plot_ly(x=ToothGrowth$len, type="histogram")
Thank you for the review!